<?php
//+------------
//|日志类
//+-----------
class Log {
	/**
	 * 文件日志 
	 * Enter description here ...
	 * @param unknown_type $content
	 * @param unknown_type $file
	 * @param unknown_type $rank
	 */
	static public function  FileLog($content,$file=NULL,$rank=0){
		$filename=date("Y-m-d");
		$file?$file=AppDir."/Runtime/Log/".$file.".log":$file=AppDir."/Runtime/Log/".$filename.".log";
		try {
			if ($f=fopen($file, "a+")){
				$content="服务器时间：[".date("Y-m-d H:i:s")."] 等级：".$rank." 日志内容如下：\r\n".$content." \r\n网址来源：http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."  来源IP：".getIP()."\r\n----------------------------------------------------------------------------------\r\n";
				return fwrite($f, $content);
			}else {
				return false;
			}
		}catch (Exception $es){
			throw $es->getMessage();
		}
		
	}
	/**
	 * 插入数据库的日志
	 * @see Ilog::DataLog()
	 */
	static public function DataLog($content,$tag=NULL,$rank=0){
		$Log=new Model();
		$Log->TableName=__TaPr__."log";
		return $Log->Create(array(
		   "LogTitle"=>date("Y-m-d H:i:s")."发生了一条日志 ",
		   "LogContent"=>$content,
		   "LogAddTime"=>times(),
		   "LogAddRank"=>(int)$tag		
		));
	    	
	}
}

?>